﻿using System;
using System.Collections.Generic;

namespace XKPlatform.Common
{
    public class WXResult_Token
    {
        /// <summary>
        /// 非0，错误
        /// </summary>
        public int errcode { get; set; }
        public string errmsg { get; set; }
        public string access_token { get; set; }
        public int expires_in { get; set; }
    }
    public class WxAppInfo
    {
        /// <summary>
        /// 非0，错误
        /// </summary>
        public int errcode { get; set; }
        /// <summary>
        /// 错误信息
        /// </summary>
        public string errmsg { get; set; }
        /// <summary>
        /// token值
        /// </summary>
        public string access_token { get; set; }
        /// <summary>
        ///  Jsapi_Ticket
        /// </summary>
        public string ticket { get; set; }
        /// <summary>
        /// 签名
        /// </summary>
        public string sign { get; set; }
        /// <summary>
        /// ticket时效
        /// </summary>
        public int expires_in { get; set; }
        /// <summary>
        /// openid
        /// </summary>
        public string openid { get; set; }
    }

    /// <summary>
    /// 企业号消息管理接口定义
    /// </summary>
    public interface ICorpMessageApi
    {
        /// <summary>
        /// 发送消息。
        /// 需要管理员对应用有使用权限，对收件人touser、toparty、totag有查看权限，否则本次调用失败。
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        CommonResult SendMessage(string url, CorpSendBase data);
    }

    public class CommonResult
    {
        public int errcode { get; set; }
        public string errmsg { get; set; }
        public string invaliduser { get; set; }
        public string invalidparty { get; set; }
        public string invalidtag { get; set; }
    }

    /// <summary>
    /// 企业号发送消息的基础消息内容
    /// </summary>
    public class CorpSendBase
    {
        /// <summary>
        /// UserID列表（消息接收者，多个接收者用‘|’分隔）。特殊情况：指定为@all，则向关注该企业应用的全部成员发送
        /// </summary>
        public string touser { get; set; }

        /// <summary>
        /// PartyID列表，多个接受者用‘|’分隔。当touser为@all时忽略本参数
        /// </summary>
        public string toparty { get; set; }

        /// <summary>
        /// TagID列表，多个接受者用‘|’分隔。当touser为@all时忽略本参数
        /// </summary>
        public string totag { get; set; }

        /// <summary>
        /// 消息类型
        /// </summary>
        public string msgtype { get; set; }

        /// <summary>
        /// 企业应用的id，整型。可在应用的设置页面查看
        /// </summary>
        public int agentid { get; set; }


        /// <summary>
        /// 表示是否是保密消息，0表示否，1表示是，默认0
        /// </summary>
        //[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
        public int safe { get; set; }

        public MiniprogramNotice miniprogram_notice { get; set; }

    }
    public class CorpSendText : CorpSendBase
    {
        public TextCard textcard { get; set; }
    }
    public class TextCard
    {
        //标题，不超过128个字节，超过会自动截断
        public string title { get; set; }
        //描述，不超过512个字节，超过会自动截断
        public string description { get; set; }
        //点击后跳转的链接
        public string url { get; set; }
        //按钮文字。 默认为“详情”， 不超过4个文字，超过自动截断。
        public string btntxt { get; set; }

    }
    public class MiniprogramNotice
    {
        public string appid { get; set; }
        public string page { get; set; }
        public string title { get; set; }
        public string description { get; set; }
        public bool emphasis_first_item { get; set; }
        public List<NoticeContentItem> content_item { get; set; }
    }

    public class NoticeContentItem
    {
        public string key { get; set; }
        public string value { get; set; }
    }
    public class WXLoginResulet
    {
        public string openid { get; set; }
        public string session_key { get; set; }
        public string unionid { get; set; }
        public int errcode { get; set; }
        public string errmsg { get; set; }
    }

    public class WXUserResulet
    {
        public string corpid { get; set; }
        public string userid { get; set; }
        public string session_key { get; set; }
        public int errcode { get; set; }
        public string errmsg { get; set; }
    }
    public class User
    {
        public string userid { get; set; }
        public string name { get; set; }
        public string mobile { get; set; }
        public string email { get; set; }
        public string[] department { get; set; }
        public string[] order { get; set; }
        public string position { get; set; }
        public extattr extattr { get; set; }
        public int enable { get; set; }
    }
    public class extattr
    {
        public List<extattr_attr> attrs { get; set; }
    }
    public class extattr_attr
    {
        public string name { get; set; }
        public string value { get; set; }
    }
    public class UserSync
    {
        public int errcode { get; set; }
        public string errmsg { get; set; }
        public List<User> UserList { get; set; }
    }

    public class Department
    {
        public string id { get; set; }
        public string name { get; set; }
        public string parentid { get; set; }
        public string order { get; set; }
    }
    public class DepartmentSync
    {
        public int errcode { get; set; }
        public string errmsg { get; set; }
        public List<Department> Department { get; set; }
    }

    public class OpenidResult
    {
        public int errcode { get; set; }
        public string errmsg { get; set; }
        public string openid { get; set; }
    }

    public class UseridResult
    {
        public int errcode { get; set; }
        public string errmsg { get; set; }
        public string userid { get; set; }
    }
    public class TagUser
    {
        public string userid { get; set; }
        public string name { get; set; }
    }
    public class TagUserSync
    {
        public int errcode { get; set; }
        public string errmsg { get; set; }
        public List<TagUser> userlist { get; set; }

    }
}